﻿using System;
using System.Collections.Generic;
using Helpers;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Core;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.LogEntries
{
	// Token: 0x020002CA RID: 714
	public class ChangeAlleyOwnerLogEntry : LogEntry, IEncyclopediaLog, IChatNotification
	{
		// Token: 0x06002A1E RID: 10782 RVA: 0x000B4452 File Offset: 0x000B2652
		internal static void AutoGeneratedStaticCollectObjectsChangeAlleyOwnerLogEntry(object o, List<object> collectedObjects)
		{
			((ChangeAlleyOwnerLogEntry)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
		}

		// Token: 0x06002A1F RID: 10783 RVA: 0x000B4460 File Offset: 0x000B2660
		protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
		{
			base.AutoGeneratedInstanceCollectObjects(collectedObjects);
			collectedObjects.Add(this.Alley);
			collectedObjects.Add(this.NewOwner);
		}

		// Token: 0x06002A20 RID: 10784 RVA: 0x000B4481 File Offset: 0x000B2681
		internal static object AutoGeneratedGetMemberValueAlley(object o)
		{
			return ((ChangeAlleyOwnerLogEntry)o).Alley;
		}

		// Token: 0x06002A21 RID: 10785 RVA: 0x000B448E File Offset: 0x000B268E
		internal static object AutoGeneratedGetMemberValueNewOwner(object o)
		{
			return ((ChangeAlleyOwnerLogEntry)o).NewOwner;
		}

		// Token: 0x17000A79 RID: 2681
		// (get) Token: 0x06002A22 RID: 10786 RVA: 0x000B449B File Offset: 0x000B269B
		public bool IsVisibleNotification
		{
			get
			{
				return this.NewOwner != null && this.NewOwner == Hero.MainHero;
			}
		}

		// Token: 0x06002A23 RID: 10787 RVA: 0x000B44B4 File Offset: 0x000B26B4
		public ChangeAlleyOwnerLogEntry(Alley alley, Hero newOwner, Hero oldOwner)
		{
			this.Alley = alley;
			this.NewOwner = newOwner;
		}

		// Token: 0x06002A24 RID: 10788 RVA: 0x000B44CA File Offset: 0x000B26CA
		public TextObject GetNotificationText()
		{
			return this.GetEncyclopediaText();
		}

		// Token: 0x06002A25 RID: 10789 RVA: 0x000B44D2 File Offset: 0x000B26D2
		public override void GetConversationScoreAndComment(Hero talkTroop, bool findString, out string comment, out ImportanceEnum score)
		{
			score = ImportanceEnum.Zero;
			comment = "";
		}

		// Token: 0x06002A26 RID: 10790 RVA: 0x000B44DF File Offset: 0x000B26DF
		public bool IsVisibleInEncyclopediaPageOf<T>(T obj) where T : MBObjectBase
		{
			return obj == this.Alley.Settlement || obj == this.NewOwner;
		}

		// Token: 0x06002A27 RID: 10791 RVA: 0x000B4504 File Offset: 0x000B2704
		public TextObject GetEncyclopediaText()
		{
			TextObject textObject;
			if (this.NewOwner != null)
			{
				textObject = GameTexts.FindText("str_alley_owner_changed_news", null);
				StringHelpers.SetCharacterProperties("HERO", this.NewOwner.CharacterObject, textObject, false);
			}
			else
			{
				textObject = GameTexts.FindText("str_alley_cleared_news", null);
			}
			textObject.SetTextVariable("SETTLEMENT", this.Alley.Settlement.EncyclopediaLinkWithName);
			textObject.SetTextVariable("COMMON_AREA", this.Alley.Name);
			return textObject;
		}

		// Token: 0x06002A28 RID: 10792 RVA: 0x000B457F File Offset: 0x000B277F
		public override string ToString()
		{
			return this.GetEncyclopediaText().ToString();
		}

		// Token: 0x04000CAB RID: 3243
		[SaveableField(60)]
		public readonly Alley Alley;

		// Token: 0x04000CAC RID: 3244
		[SaveableField(61)]
		public readonly Hero NewOwner;
	}
}
